package com.ygqh.baby.controller.open;

import com.ygqh.baby.ao.ResponseEntity;
import com.ygqh.baby.po.YgUser;
import com.ygqh.baby.service.YgUserService;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@CrossOrigin
@RequestMapping("/open/user")
@RestController
public class UserController extends KidsBaseController {
    private Logger logger = org.slf4j.LoggerFactory.getLogger(getClass());

    @Autowired
    private YgUserService ygUserService;

    @RequestMapping("/findUser")
    @ResponseBody
    public ResponseEntity findUser(@RequestParam String userName, HttpServletRequest request) {
        ResponseEntity validToken = validToken(request);
        if (!validToken.isSuccess()) {
            return validToken;
        }
        YgUser user = ygUserService.findByUserName(userName);
        return ResponseEntity.success(user);

    }

}
